package org.elephantt.webby;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;

/**
 * Cookie utilities
 */
public class CookieUtil {
  public static void clearCookie(Request request, HttpServletResponse response, String key) {
    Cookie cookie = request.getCookie(key);

    if (cookie != null) {
      cookie.setValue(null);
      cookie.setMaxAge(0);
      cookie.setPath("/");
      response.addCookie(cookie);
    }
  }
}
